package p6;

/**
 * @author krystal
 * @date 2022/11/11 19:47
 */
class Cat{
    public String name;
    public String color;
    public int age;

    public Cat(String name,String color,int age){
        this.name=name;
        this.color=color;
        this.age=age;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", color='" + color + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Demo4 {
    public static void main(String[] args) {
        Cat cat=new Cat("梦龙","white",1);
        //方法一
        String ret=cat.toString();
        System.out.println(ret);
        //方法二
        System.out.println(cat);
    }
}
